package com.hnkywl.sts.entity.jhgl;

import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.organ.Qyjg;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Where;

import javax.persistence.*;

/**
 * 说明：三方协议
 * 包:        com.hnkywl.sts.entity.jhgl
 * 类描述:    三方协议
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Entity
@Where(clause = "deleted!='1'")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("sfxy")
public class Sfxy extends Xy {
    /**
     * 供应商
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="GYS_ID")
    private Qyjg gys;

    /**
     * 客户
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="KH_ID")
    private Qyjg kh;

    /**
     * 回款期限
     */
    private Integer hkqx;

    /**
     * 回款计算方式
     */
    @ManyToOne
    @JoinColumn(name="SJZDZ_HKJSFS_ID")
    private Sjzdz hkjsfs;

    @Formula(" (select sum(t.sbsl) from T_BIZ_CGDMX t left join  T_BIZ_CGD a on t.cgd_id=a.id " +
            "left join T_BIZ_HT ht on a.cght_id=ht.id left join T_BIZ_XY xy on ht.xy_id=xy.id " +
            "where t.yjs=1 and xy.id=ID) ")
    private Double yzxl;

    public Qyjg getGys() {
        return gys;
    }

    public void setGys(Qyjg gys) {
        this.gys = gys;
    }

    public Qyjg getKh() {
        return kh;
    }

    public void setKh(Qyjg kh) {
        this.kh = kh;
    }

    public Integer getHkqx() {
        return hkqx;
    }

    public void setHkqx(Integer hkqx) {
        this.hkqx = hkqx;
    }

    public Sjzdz getHkjsfs() {
        return hkjsfs;
    }

    public void setHkjsfs(Sjzdz hkjsfs) {
        this.hkjsfs = hkjsfs;
    }

    public Double getYzxl() {
        return yzxl;
    }

    public void setYzxl(Double yzxl) {
        this.yzxl = yzxl;
    }
}
